/**
 *
 */
package com.lgCore.server.factory;

import com.lgCore.netty.server.NettyServerBootstrap;
import com.lgCore.server.workHandler.ICommonRpcRouteService;
import com.lgCore.server.workHandler.impl.ICommonRpcRouteServiceImpl;
import com.lgCore.util.IpAddr;

/**
 * @author ligang
 * server服务工厂
 * 1打开netty通信
 * 2service 注册
 */
public class CommonRpcServiceFactory {
    private static ICommonRpcRouteService iCommonRpcRouteService;

    private static NettyServerBootstrap serverBootStrap;

    static {
        try {
            registerProtocol(new ICommonRpcRouteServiceImpl(), new NettyServerBootstrap(IpAddr.getNewPort()));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    private static void registerProtocol(ICommonRpcRouteService iCommonRpcRouteServiceImpl, NettyServerBootstrap bootStrap) {
        iCommonRpcRouteService = iCommonRpcRouteServiceImpl;
        serverBootStrap = bootStrap;
    }

    public static ICommonRpcRouteService getCommonRpcRouteService() {
        return iCommonRpcRouteService;
    }

    public static NettyServerBootstrap getServerBootStrap() {
        return serverBootStrap;
    }
}
